#define _CRT_SECURE_NO_WARNINGS 1

struct TreeNode* invertTree(struct TreeNode* root) {
	if (root == NULL)
		return root;

	if (root->left && root->right)
		return root;

	if (root->left == NULL)
	{
		int tmp = root->right->val;
		root->left->val = tmp;
		root->right = NULL;
	}
	if (root->right == NULL)
	{
		int tmp = root->left->val;
		root->right->val = tmp;
		root->left = NULL;
	}

	int tmp = root->left->val;
	root->left->val = root->right->val;
	root->right->val = tmp;

	invertTree(root->left);
	invertTree(root->right);

	return root;


}